.TH std::chrono::weekday_indexed 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::chrono::weekday_indexed \- std::chrono::weekday_indexed

.SH Synopsis
   Defined in header <chrono>
   class weekday_indexed;      \fI(since C++20)\fP

   The class weekday_indexed combines a weekday, representing a day of the week in the
   proleptic Gregorian calendar, with a small index n in the range [1, 5]. It
   represents the first, second, third, fourth, or fifth weekday of some month.

   weekday_indexed is a TriviallyCopyable StandardLayoutType.

.SH Member functions

   constructor   constructs a weekday_indexed
                 \fI(public member function)\fP
   weekday       access the stored weekday
                 \fI(public member function)\fP
   index         access the stored index
                 \fI(public member function)\fP
   ok            checks if the weekday and index are both valid
                 \fI(public member function)\fP

   Nonmember functions

   operator== compares two weekday_indexed values
   (C++20)    \fI(function)\fP
   operator<< outputs a weekday_indexed into a stream
   (C++20)    \fI(function template)\fP

.SH Helper classes

   std::formatter<std::chrono::weekday_indexed> formatting support for weekday_indexed
   (C++20)                                      \fI(class template specialization)\fP
   std::hash<std::chrono::weekday_indexed>      hash support for
   (C++26)                                      std::chrono::weekday_indexed
                                                \fI(class template specialization)\fP

.SH Example


// Run this code

 #include <chrono>
 #include <iostream>

 int main()
 {
     using namespace std::chrono;

     constexpr weekday_indexed wi = Friday[2];

     // Indexed weekday can be used at any place where chrono::day can be used:
     constexpr year_month_weekday ymwd = 2021y / August / wi;
     static_assert(ymwd == August / wi / 2021y &&
                   ymwd == wi / August / 2021y);
     std::cout << ymwd << '\\n';

     constexpr year_month_day ymd{ymwd}; // a conversion
     static_assert(ymd == 2021y / 8 / 13);
     std::cout << ymd << '\\n';
 }

.SH Possible output:

 2021/Aug/Fri[2]
 2021-08-13
